using System;
using NUnit.Framework;
using QuickStart;
using Microsoft.Xna.Framework;

namespace UnitTest.MessageSystem
{
    /// <summary>
    /// Unit test for the Message class
    /// </summary>
    [TestFixture]
    public class Message
    {
        /// <summary>
        /// Tests the properties of the Message class
        /// </summary>
        [Test]
        public void PropertyTest()
        {
            Message<string> message = new Message<string>();
            
            message.Data = "Some Text";
            Assert.AreEqual(message.Data, "Some Text", "The data property was not set correctly");

            message.Time = new GameTime(TimeSpan.FromMilliseconds(1), TimeSpan.FromMilliseconds(2), TimeSpan.FromMilliseconds(3), TimeSpan.FromMilliseconds(4), false);
            Assert.AreEqual(message.Time.TotalRealTime.Milliseconds, 1, "The TotalRealTime is incorrect");
            Assert.AreEqual(message.Time.ElapsedRealTime.Milliseconds, 2, "The ElapsedRealTime is incorrect");
            Assert.AreEqual(message.Time.TotalGameTime.Milliseconds, 3, "The TotalGameTime is incorrect");
            Assert.AreEqual(message.Time.ElapsedGameTime.Milliseconds, 4, "The ElapsedGameTime is incorrect");
            Assert.IsFalse(message.Time.IsRunningSlowly, "IsRunningSlowly is incorrect");

            message.Type = 100;
            Assert.AreEqual(message.Type, 100, "Message type not set correctly");
        }

        /// <summary>
        /// Tests the Release method
        /// </summary>
        [Test]
        public void Release()
        {
            Message<string> message = new Message<string>();
            message.Data = "Some Text";
            message.Type = 100;
            message.Time = new GameTime();

            ((IPoolItem)message).Release();

            Assert.AreEqual(message.Data, default(string), "Data property was not reset correctly");
            Assert.AreEqual(message.Time, null, "Time is not reset correctly");
            Assert.AreEqual(message.Type, MessageType.Unknown, "Type not reset correctly");
        }
    }
}
